import { Component, OnInit, ViewChild } from '@angular/core';
import { SFComponent, SFSchema, SFTextareaWidgetSchema, SFUISchema } from '@delon/form';
import { _HttpClient } from '@delon/theme';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { ClaimAuditService } from '../../services/claim-audit.service';

@Component({
  selector: 'app-parter-claim-audit-partner-approve',
  templateUrl: './partner-approve.component.html'
})
export class ParterClaimAuditListPartnerApproveComponent implements OnInit {
  @ViewChild('sf', { static: false }) sf!: SFComponent;
  schema!: SFSchema;
  ui!: SFUISchema;
  i: any;
  type: any;

  constructor(public service: ClaimAuditService, private modalRef: NzModalRef) {}

  ngOnInit(): void {
    this.initSF();
  }
  initSF() {
    this.schema = {
      properties: {
        id: {
          type: 'string',
          title: '',
          ui: { hidden: true }
        },
        name1: {
          title: '合伙人(认领人)',
          type: 'string',
          ui: {
            widget: 'text'
          }
        },
        name2: {
          title: '认领客户名称',
          type: 'string',
          ui: {
            widget: 'text'
          }
        },
        data: {
          title: '结算起算日期',
          type: 'string',
          format: 'date'
        },
        name3: {
          type: 'string',
          title: '备注',
          maxLength: 50,
          ui: {
            widget: 'textarea',
            autosize: { minRows: 3, maxRows: 6 },
            placeholder: '请不要超过50个字'
          } as SFTextareaWidgetSchema
        }
      },
      required: ['name3']
    };
    this.ui = {
      '*': {
        spanLabelFixed: 120,
        grid: { span: 24 }
      }
    };
  }

  close() {
    this.modalRef.destroy();
  }
  save() {
    this.sf.validator({ emitError: true });
    if (!this.sf.valid) return;
    // this.service.request('', { ...this.sf?.value }).subscribe(res => {
    //   if (res) {
    //     this.modalRef.destroy(true);
    //   } else {
    //     this.service.msgSrv.error(res.msg);
    //   }
    // });
  }
}
